<#include "layout/template.ftl"/>

<@htmlHead title="优惠券批次列表">
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${resources}/assets/css/jquery-ui.css" />
		<link rel="stylesheet" href="${resources}/assets/css/datepicker.css" />
		<link rel="stylesheet" href="${resources}/assets/css/ui.jqgrid.css" />
		<link rel="stylesheet" href="${resources}/plugins/jqgrid/4.6/jqgrid.extend.css" />
		
		
</@htmlHead>


 
<@htmlBody 'coupon' 'couponManage'>

	<!-- breadcrumbs begin -->
	<#include "layout/breadcrumbs.ftl">
	<@breadcrumbs '优惠券批次管理' '优惠券批次列表'></@breadcrumbs>
	<!-- breadcrumbs start -->

	<!-- page-content begin -->
	<div class="page-content">
			
			<!-- page-header begin -->
			<div class="page-header">
				<h1>
					<i class="fa fa-trophy"></i>&nbsp;优惠券批次列表
					<a href="${path}/manage/coupon/coupon/create" class="btn btn-warning pull-right">
						<i class="ace-icon fa fa-plus"></i> 新 增
					</a>
				<h1>
				
				<!--查询 条件  begin -->
				<div style="margin-top:20px;padding:10px 0px 0px 0px;border-top:1px solid #307ecc">
					<div style="float:right">
						<button id="find_btn"  class="btn btn-primary">
							<i class="ace-icon fa fa-search"></i>查 询
						</button>
				    </div>
				    
				    <div id="query" class="query-view" style="">
						<ul class="list-inline">
						 	<li> 
					       		<label>优惠券批次名称：</label><input type="text" class="input-sm" id="name"  name="name" data-op="cn" /> 
				  		 	</li> 
				  		 </ul>
					</div>
				    
				</div>
				<!-- 查询条件 end-->
			</div>
			<!-- page-header end -->

			<!-- jqGrid begin -->
			<div class="row">	
				<div class="col-md-12">
				  	<table id="grid-table"></table>
			 		<div id="grid-pager"></div>
				</div>
			</div>	
			<!-- jqGrid end -->
	</div>		
	<!-- page-content end -->	


			

</@htmlBody>



<@htmlBodyScript>

	 	<!-- 日期控件-->
	 	<script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/bootstrap-datetimepicker.js"></script>
	   	<script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
		<script>
			$("#starttime,#endtime").datetimepicker({
				bootcssVer:3,
			    format: "yyyy-mm-dd",
			    language:"zh-CN",
				weekStart: 1,
	        	todayBtn:  1,
				autoclose: 1,
				todayHighlight: 1,
				startView: 2,
				minView: 2,
				forceParse: 0
			});
		</script>
		<script src="${resources}/assets/js/date-time/bootstrap-datepicker.js"></script>
		<script src="${resources}/assets/js/jqGrid/jquery.jqGrid.src.js"></script>
		<script src="${resources}/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>
		
           <!-- 格式化货币 -->
		<script src="${resources}/plugins/tool/accounting.min.js"></script>
		<script src="${resources}/assets/js/date-time/bootstrap-datepicker.js"></script>
		<script src="${resources}/assets/js/jqGrid/jquery.jqGrid.src.js"></script>
		<script src="${resources}/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>

		<script>
		
			var $path ='${path}';
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";
			
			$(function(){
				//分页插件开始
				$("#grid-table").jqGrid({
					url: '${path}/manage/coupon/coupon/list',
				 	mtype : "post", 
					datatype: "json",
					//prmNames : {search : "search"},  
					colNames:[ 'ID','名称','模式','唯一标识','生码数量','面值','最小订单金额','开始时间','结束时间','创建时间','操作'],
				 	colModel: [
						{name:'id', width:30},
						{name:'name'},
						{
							name:'mode',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								if(cellValue==1){
									return "纸质";
								}else if(cellValue==2){
									return "完善地址系统发放"
								}else if(cellValue==3){
								    return "电子优惠券"
								}
							}
						},
						{name:'uid',width:100},
						{name:'quantity',width:100},
						{
							name:'rule.usageAmount',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								return accounting.formatMoney(cellValue, "¥", 2, ",", ".");
							}
						},
						{
							name:'rule.minAmount',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								return accounting.formatMoney(cellValue, "¥", 2, ",", ".");
							}
						},
						{
							name:'rule.startTime',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								var output = moment(cellValue).format('YYYY-MM-DD');
								return output;
							}
						},
						{
							name:'rule.endTime',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								var output = moment(cellValue).format('YYYY-MM-DD ');
								return output;
							}
						},
						{
							name:'createTime',
							width:100,
							formatter:function(cellValue, options, rowObject) {
								var output = moment(cellValue).format('YYYY-MM-DD HH:mm:ss');
								return output;
							}
						},
						{
							name:'id',
							width: 150,
							sortable:false,
							formatter :function(cellvalue, options, rawObject) {
					    		var option = '<div class="ui-op">';
				    		 	option = option +'</a>';
				    		 	if(rawObject.mode==1){
					    			option = option +'<a class=""  data-toggle="tooltip" data-placement="bottom" title="下载"  tag="'+cellvalue+'"  href="${path}/manage/coupon/coupon/download/'+cellvalue+'"  onclick="return downing()">下载';
				              	  option = option +'</a>';
				                }
								option = option +'<a class=""  data-toggle="tooltip" data-placement="bottom" title="编辑"  tag="'+cellvalue+'"  href="${path}/manage/coupon/coupon/update/'+cellvalue+'" >编辑';
				                option = option +'</a>';
				                
							 	option	 = option +'</a>'; 
				                option = option +'</div>';      
			               		return option;  
							}
						}
					],
					viewrecords: true, 							// 在toolbar显示的当前页数,步长,总数
					autowidth: true,								//自动宽度
					height: 350,
					rowNum: 10,
					rowList:[10,20,30],
					sortname: 'id',
					sortorder: 'desc',
					pager: "#grid-pager",
					caption: "列表",
					loadComplete : function() {
						var table = this;
						setTimeout(function(){
							styleCheckbox(table);
							updateActionIcons(table);
							updatePagerIcons(table);
							enableTooltips(table);
						}, 0);
					}
					
				});
				//分页插件结束
				
				//------------------------------- 自定义查询开始 -------------------------------
				//自定义查询开始
				$("#find_btn").click(function(){ 
					searchData('${path}/manage/coupon/coupon/list');
			    }); 
				//自定义查询结束
				
				
				
			})
			function downing(){
					var is=confirm("是否下载该优惠券?");
					if(is==false){
						return false;
					}else{
						if('正在下载中' !==undefined){
								_letsun_show_msg("info","正在下载中,请稍后......",2000);
						}
					}
			}
			
		</script>
		<#-- 操作提示 -->
	
	
	    <script src="${resources}/assets/js/jqGrid/jquery.jqGrid.Extract.js"></script>

</@htmlBodyScript>